package com.cxd.app.service;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.cxd.app.entity.base.TrusteeshipOperationBase;
import com.cxd.base.mapper.write.WManageMapper;
import com.cxd.base.util.BeanTools;

/**
 * <一句话功能简述> <功能详细描述>
 * @author wtj
 * @date 2015年12月5日 下午5:43:20
 * @company CXD
 * @version [Copyright (c) 2015 V001]
 */
@Service("trusteeshipOperationService")
public class TrusteeshipOperationService {
	@Resource
	public BeanTools bt;
	
	@Resource
	WManageMapper wmanageMapper;
	
	/**
	 * 操作类型（type） 操作的唯一标识（markId） 托管方(trusteeship) 上述三者一致，则认为是同一条数据。
	 */
	@Transactional
	public void save(TrusteeshipOperationBase to) {
		if (StringUtils.isEmpty(to.getType())) {
			throw new IllegalArgumentException(
					"trusteshipOperation.type can not be empty!");
		}
		if (StringUtils.isEmpty(to.getMarkId())) {
			throw new IllegalArgumentException(
					"trusteshipOperation.markId can not be empty!");
		}
		if (StringUtils.isEmpty(to.getTrusteeship())) {
			throw new IllegalArgumentException(
					"trusteshipOperation.trusteeship can not be empty!");
		}
		bt.del("TRUSTEESHIP_OPERATION", new String[]{"TYPE","MARK_ID","trusteeship"},
											new String[] { to.getType(), to.getMarkId(),to.getTrusteeship() });
		
		wmanageMapper.saveTrusteeshipOperation(to);
//		bt.add(to);
	}
}
